home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Printing / ImageWriter bug / IW 6.1⁄7.0 work-around < prev   
Encoding:
Text File  |  1992-07-15  |  1.8 KB  |  87 lines  |  [TEXT/MPS ]

  1. (* Sample snippet that demonstrates how to work-around the
  2.    'dctb' bug in the ImageWriter II 6.1 and 7.0 drivers.
  3.    Bug causes a crash when doing a style dialog
  4.    after setting draftbits with PrGeneral.
  5.  *)
  6.  
  7. {
  8.     What's what in the code snippet that follows.
  9.     
  10.     thePrRecHdl        : THPrint;
  11.     rslData            : TSetRslBlk;
  12.     draftData        : TDftBitsBlk;
  13.     rotnData        : TGetRotnBlk;
  14.     isBadImageWriter: Boolean;
  15.     isLandscape        : Boolean;
  16.     isReduced        : Boolean;
  17. }
  18.  
  19.         PrOpen;
  20.  
  21.         IF (PrError = noErr) THEN
  22.         BEGIN
  23.  
  24.             PrintDefault(thePrRecHdl);
  25.  
  26.             IF (PrError = noErr) THEN
  27.             BEGIN
  28.  
  29. {See if we're using a version 6.1 or 7.0 ImageWriter driver.}
  30.  
  31.                 IF (thePrRecHdl^^.prStl.wDev DIV 256) = 1 THEN
  32.                     isBadImageWriter := (PrDrvrVers = 61) OR (PrDrvrVers = 70)
  33.                 ELSE
  34.                     isBadImageWriter := FALSE;
  35.                     
  36.                 IF NOT (isBadImageWriter) THEN
  37.                 BEGIN
  38.  
  39. {Set draftBits mode now, if not our special case.}
  40.  
  41.                     draftData.iOpCode := draftBitsOp;
  42.                     draftData.hPrint := thePrRecHdl;
  43.                     PrGeneral(@draftData);
  44.  
  45.                 END;
  46.  
  47. {Do the style dialog.}
  48.  
  49.                 IF (PrStlDialog(thePrRecHdl)) THEN
  50.                     IF (isBadImageWriter) THEN
  51.                     BEGIN
  52.  
  53. {If so, see if they selected rotation or 50% reduction.}
  54.                     
  55.                         rotnData.iOpCode := getRotnOp;
  56.                         rotnData.hPrint := thePrRecHdl;
  57.                         PrGeneral(@rotnData);
  58.  
  59.                         isLandscape := rotnData.fLandscape;
  60.  
  61.                         isReduced := BTst(thePrRecHdl^^.prStl.wDev, 3);
  62.  
  63. {If so, warn them that those things will be ignored.
  64.  Preferably use something other than DebugStr…        }
  65.                     
  66.                         IF (isLandscape) OR (isReduced) THEN
  67.                             DebugStr('Bad ImageWriter; landscape and/or reduced.');
  68.  
  69. {Now, set draftBits mode, since we didn't before.}
  70.  
  71.                         draftData.iOpCode := draftBitsOp;
  72.                         draftData.hPrint := thePrRecHdl;
  73.                         PrGeneral(@draftData);
  74.  
  75.                     END;
  76.  
  77.                     IF (PrJobDialog(thePrRecHdl)) THEN 
  78.                     BEGIN
  79.  
  80.                         {Print}
  81.  
  82.                     END;
  83.             END;
  84.         END;
  85.  
  86.         PrClose;
  87.